#!/bin/sh
file_rrd_name=$1
file_img_name=$2
/usr/local/rrdtool-1.2.15/bin/rrdtool graph $file_img_name/cpu_day.png \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="CPU Usage(day)" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="percent" \
DEF:a="$file_rrd_name/cpu_system":cpu_system:AVERAGE \
DEF:b="$file_rrd_name/cpu_user":cpu_user:AVERAGE \
LINE1:a#FF0000:"System"  \
GPRINT:a:LAST:"Current\:%8.2lf %s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n"  \
LINE1:b#0000FF:"User"  \
GPRINT:b:LAST:"  Current\:%8.2lf %s"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" 


/usr/local/rrdtool-1.2.15/bin/rrdtool graph $file_img_name/cpu_weekly.png \
--imgformat=PNG \
--start=-604800 \
--end=-1800 \
--title="CPU Usage(weekly)" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="percent" \
DEF:a="$file_rrd_name/cpu_system":cpu_system:AVERAGE \
DEF:b="$file_rrd_name/cpu_user":cpu_user:AVERAGE \
LINE1:a#FF0000:"System"  \
GPRINT:a:LAST:"Current\:%8.2lf %s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n"  \
LINE1:b#0000FF:"User"  \
GPRINT:b:LAST:"  Current\:%8.2lf %s"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" 

/usr/local/rrdtool-1.2.15/bin/rrdtool graph $file_img_name/cpu_monthly.png \
--imgformat=PNG \
--start=-2678400 \
--end=-7200 \
--title="CPU Usage(monthly)" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="percent" \
DEF:a="$file_rrd_name/cpu_system":cpu_system:AVERAGE \
DEF:b="$file_rrd_name/cpu_user":cpu_user:AVERAGE \
LINE1:a#FF0000:"System"  \
GPRINT:a:LAST:"Current\:%8.2lf %s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n"  \
LINE1:b#0000FF:"User"  \
GPRINT:b:LAST:"  Current\:%8.2lf %s"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" 

/usr/local/rrdtool-1.2.15/bin/rrdtool graph $file_img_name/cpu_yearly.png \
--imgformat=PNG \
--start=-33053184 \
--end=-86400 \
--title="CPU Usage(yearly)" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="percent" \
DEF:a="$file_rrd_name/cpu_system":cpu_system:AVERAGE \
DEF:b="$file_rrd_name/cpu_user":cpu_user:AVERAGE \
LINE1:a#FF0000:"System"  \
GPRINT:a:LAST:"Current\:%8.2lf %s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n"  \
LINE1:b#0000FF:"User"  \
GPRINT:b:LAST:"  Current\:%8.2lf %s"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" 
